home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group95c.txt / 000110_icon-group-sender _Mon Dec 4 14:17:05 1995.msg < prev    next >
Internet Message Format  |  1996-01-03  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 4 Dec 1995 16:34:33 MST
  2. Date: Mon, 4 Dec 1995 14:17:05 -0800
  3. From: kwalker@orville.premenos.com (Ken Walker)
  4. Message-Id: <9512042217.AA05047@orville.orville.premenos.com.>
  5. To: icon-group@cs.arizona.edu, lindsay-j@rmc.ca
  6. Subject: Re: Generators and/vs. coroutines ?
  7. X-Sun-Charset: US-ASCII
  8. Errors-To: icon-group-errors@cs.arizona.edu
  9.  
  10. > Date: 4 Dec 1995 17:01:09 GMT
  11. > From: John Lindsay <lindsay-j@rmc.ca>
  12. >...
  13. > Is an Icon generator anything more or less than a coroutine which can 
  14. > be instantiated by an explicit call with value arguments, and can 
  15. > 'return' a function value across the coroutine boundary ?  
  16.  
  17. A generator is less than a coroutine (but, as they say, "less is more" ;-). This can
  18. been seen in the way the two are implemented. A coroutine is given its own call stack,
  19. but a generator isn't. A generator is a function that stays on the call stack as
  20. long is it might be resumed to produce another value. This works well because a generator
  21. is never resumed until everything called after it has terminated and been removed
  22. from the stack; backtracking is last-in first-out. When a generator is resumed, the
  23. call stack has returned to the state it was in when the generator suspended. Note,
  24. if you are trying to use the call stack as an expression evaluation stack (as is sometimes
  25. done in interpreters), the long-lived stack frames get in the way, but that can be
  26. dealt with by employing some extra copying of intermediate values around the suspended
  27. stack frames to the top of the stack.
  28.  
  29. Ken Walker, kwalker@premenos.com
  30. Premenos Coporation, Concord, Ca. 94520
  31.